package com.cgnpc.scp.filter;

import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;

public class CharSafeServletInputStream extends ServletInputStream {
    private ByteArrayInputStream inputStream;

    public CharSafeServletInputStream(ByteArrayInputStream inputStream) {
        this.inputStream = inputStream;
    }

    @Override
    public int read() throws IOException {
        if (this.inputStream != null) {
            return inputStream.read();
        }

        return -1;
    }

    @Override
    public boolean isFinished() {
        return false;
    }

    @Override
    public boolean isReady() {
        if (this.inputStream != null) {
            return true;
        }

        return false;
    }

    @Override
    public void setReadListener(ReadListener listener) {

    }

}
